优雅的文字渐变动画,为界面增添活力
流畅的色彩过渡效果,文字如彩虹般流动
无需JavaScript,轻量级高性能解决方案
在各种设备上完美呈现,移动端友好
以下是如何实现渐变文字效果的CSS代码
/* 基础渐变文字效果 */
.gradient-text {
display: inline-block;
background: linear-gradient(90deg,
#ff0a78,
#7d00ff,
#00a3ff,
#ff0a78);
-webkit-background-clip: text;
background-clip: text;
-webkit-text-fill-color: transparent;
background-size: 300% 300%;
animation: gradientFlow 4s linear infinite;
}
/* 动画关键帧 */
@keyframes gradientFlow {
0% { background-position: 0% 50%; }
50% { background-position: 100% 50%; }
100% { background-position: 0% 50%; }
}
/* 应用示例 */
.title-text {
font-size: 32px;
font-weight: 700;
}
.subtitle-text {
font-size: 18px;
font-weight: 500;
}
.feature-title {
font-size: 20px;
font-weight: 600;
}
创建包含多种颜色的线性渐变背景
使用background-clip:text使背景仅透过文字显示
通过改变背景位置实现流动效果